﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using Hi_Baidu.ProcessModel;

namespace Hi_Baidu.Timer
{
    /// <summary>
    ///     提供了获取分组操作的计时操作和后续处理
    /// </summary>
    class GetGroupTimeOutEvent : TimeOutEvent
    {
        private String username;

        public GetGroupTimeOutEvent(String username, String Key, int Interval, int TryCount)
            : base(Key, Interval, TryCount)
        {
            this.username = username;
            this.OnTick += new EventHandler<EventArgs>(GetGroupTimeOutEvent_OnTick);
            this.OnTryFull += new EventHandler<EventArgs>(GetGroupTimeOutEvent_OnTryFull);
        }

        void GetGroupTimeOutEvent_OnTick(object sender, EventArgs e)
        {
            //重试获取分组信息
            GetInfomationModel.GetUserGroupInfo(Encoding.Default.GetBytes(username));
        }

        void GetGroupTimeOutEvent_OnTryFull(object sender, EventArgs e)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new PUBLIC_DELEGATE(Globle.ShowWindow));
        }
    }
}
